package cn.ehanghai.iot.idcard;

import cn.ehanghai.iot.dataobject.IdCard;
import cn.ehanghai.iot.utils.HttpUitl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;



/**
 * 身份证认证接口
 * @Author: xumf
 * @Date: 2019/7/8 12:19
 */
public class IdCardUtil {

    public static IdCard getIdCardInfo(String cardNo){

            String url="http://api.k780.com:88/";
            String param="app=idcard.get&idcard="+cardNo+"&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json";
            String result= HttpUitl.sendGet(url,param);
            System.out.println(result);
            JSONObject json= JSON.parseObject(result);
            if(json.get("success").equals("1")){
                String resultJson=json.getString("result");
                IdCard idCard= new Gson().fromJson(resultJson,IdCard.class);
                System.out.println(idCard.getAtt());
                return idCard;
            }
            return  null;
    }

    public static void main(String[] args) {
        getIdCardInfo("511025199701021699");
    }
}
